﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://wpfimageviewer.codeplex.com
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Reflection;
using System.Windows;
using BrainTechLLC;
using BrainTechLLC.WPF;
using BrainTechLLC.ThreadSafeObjects;

namespace EventWindowHandler.Plugin
{
    public class EventCallInfoViewModel : GenericViewModelBase<EventCallInfoViewModel, EventCallInfo>, INotifyPropertyChanged
    {
        public Type _objectInstanceType;
        public object _objectInstance;

        public EventCallInfoViewModel(EventCallInfo info, object objectInstance, Type objectInstanceType)
        {
            _objectInstance = objectInstance;
            _objectInstanceType = objectInstanceType;
            Item = info;
        }

        public Type ObjectInstanceType
        {
            get { return _objectInstanceType; }
        }

        public object ObjectInstance
        {
            get { return _objectInstance; }
        }

        public string ObjectInstanceTypeName
        {
            get { return _objectInstanceType == null ? "null" : _objectInstanceType.Name; }
        }

        public string ObjectInstanceName
        {
            get { return _objectInstance == null ? "null" : _objectInstance.ToString(); }
        }

        //public Type EventArgsType
        //{
        //    get { return _info.EventArgsType; }
        //}

        public string EventArgsTypeName
        {
            get { return Item.EventArgsType.Name; }
        }

        public string TargetName
        {
            get { return Item.Target == null ? string.Empty : Item.Target.ToString(); }
        }

        //public object Target
        //{
        //    get { return _info.Target; }
        //}

        //public Type TargetType
        //{
        //    get { return _info.TargetType; }
        //}

        //public MethodInfo TargetMethod
        //{
        //    get { return _info.TargetMethod; }
        //}

        public string TargetTypeName
        {
            get { return Item.TargetType == null ? "Static" : Item.TargetType.Name; }
        }

        public Visibility PropChangedVisibility
        {
            get { return (typeof(PropertyChangedEventArgs).IsAssignableFrom(Item.EventArgsType)) ? Visibility.Visible : Visibility.Collapsed; }
        }

        public string PropertyValueAtTime
        {
            get { return Item.PropertyValueAtTime == null ? "null" : Item.PropertyValueAtTime.ToString(); }
        }

        public string PropertyName
        {
            get { return Item.AdditionalInfo as string; }
        }

        public string TargetMethodName
        {
            get { return Item.TargetMethod.Name; }
        }
    }
}
